<?php if ($comfy['ajaxtabs'] == true) : ?>
<div class="box_a" id="widget_T">

	<h2><?php print HOT_TOPICS; ?><a href="#minimize" class="Sminimize"></a><a href="#close" class="Sclose"></a></h2>
	<div style="padding:0 0 0 0">
	
	<ul id="tabs" class="tabs">
		<li><a href="#recent-topics" rel="recent" class="selected"><?php print RECENT_TOPICS; ?></a></li>
		<li><a href="#most-viewed" rel="viewed"><?php print MOST_VIEWED; ?></a></li>
		<li><a href="#most-discussed" rel="discussed"><?php print MOST_DISCUSSED; ?></a></li>
	</ul><div class="clear"></div>
	
	<ul id="recent" class="tabcontent">
	<?php wp_get_archives('type=postbypost&limit='.$comfy['recent_num'].'&format=html'); ?>
	</ul>

	<ul id="viewed" class="tabcontent">
	<?php if (function_exists('get_most_viewed')): ?>
	<?php get_most_viewed('post', $comfy['viewed_num']); ?>
	<?php endif; ?>
	</ul>
	
	<ul id="discussed" class="tabcontent">
	<?php
	$now = gmdate("Y-m-d H:i:s",time());
	$ap = $comfy['discussed_num'];
	$popularposts = "SELECT ID, post_title, post_date, comment_count, COUNT($wpdb->comments.comment_post_ID) AS 'popular' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY popular DESC LIMIT $ap";
	$posts = $wpdb->get_results($popularposts);
	$popular = '';
	if($posts){
	foreach($posts as $post){
	$post_title = stripslashes($post->post_title);
	$post_date = stripslashes($post->post_date);
	$comments = stripslashes($post->comment_count);
	$guid = get_permalink($post->ID);
	$popular .= '<li><a href="'.$guid.'#comments" title="'.$post_title.'">'.$post_title.' <span>'.DISCUSSED.' '.$comments.' '.TIMES.'</span></a></li>';
	}
	}echo $popular;
	?>
	</ul>
	
	<script type="text/javascript">
	var tabs=new ddtabcontent("tabs")
	tabs.setpersist(false)
	tabs.setselectedClassTarget("link")
	tabs.init()
	</script>
	
	</div>

<span class="foot"></span>
</div>
<?php endif; ?>